<template>
  <div class="home">
    <header class="hero">
      <div class="hero-content">
        <h1 class="glitch"
            data-text="欢迎来到我的博客">欢迎来到我的博客</h1>
        <p class="subtitle">分享技术与生活的点点滴滴</p>
      </div>
    </header>

    <main class="content">
      <section class="blog-posts">
        <article v-for="post in posts"
                 :key="post.id"
                 class="post-card"
                 @mouseenter="handleHover"
                 @mouseleave="handleLeave"
                 @click="goToArticle(post.id)">
          <div class="post-content">
            <h2>{{ post.title }}</h2>
            <p>{{ post.excerpt }}</p>
            <span class="date">{{ post.date }}</span>
          </div>
        </article>
      </section>
    </main>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import gsap from 'gsap';
import { useRouter } from 'vue-router';

const router = useRouter();
const posts = ref([
  {
    id: 1,
    title: '我的第一篇博客',
    excerpt: '这是一个使用 Vue3 和 Three.js 构建的个人博客...',
    date: '2024-03-20'
  },
  {
    id: 2,
    title: 'Three.js 入门指南',
    excerpt: '了解如何使用 Three.js 创建炫酷的 3D 效果...',
    date: '2024-03-19'
  }
]);

const handleHover = (event) => {
  gsap.to(event.currentTarget, {
    scale: 1.02,
    duration: 0.3,
    ease: 'power2.out',
    boxShadow: '0 8px 16px rgba(0,0,0,0.2)'
  });
};

const handleLeave = (event) => {
  gsap.to(event.currentTarget, {
    scale: 1,
    duration: 0.3,
    ease: 'power2.in',
    boxShadow: '0 4px 6px rgba(0,0,0,0.1)'
  });
};

const goToArticle = (id) => {
  router.push(`/article/${id}`);
};
</script>

<style scoped>
.home {
  padding: 2rem;
  min-height: 100vh;
}

.hero {
  text-align: center;
  padding: 6rem 2rem;
  position: relative;
  overflow: hidden;
}

.hero-content {
  position: relative;
  z-index: 1;
}

.glitch {
  font-size: 4rem;
  font-weight: bold;
  text-transform: uppercase;
  position: relative;
  text-shadow: 0.05em 0 0 rgba(255,0,0,0.75),
              -0.025em -0.05em 0 rgba(0,255,0,0.75),
              0.025em 0.05em 0 rgba(0,0,255,0.75);
  animation: glitch 500ms infinite;
  color: #fff;
}

.subtitle {
  font-size: 1.5rem;
  color: #fff;
  margin-top: 1rem;
  opacity: 0.8;
}

.content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.blog-posts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

.post-card {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 15px;
  padding: 2rem;
  transition: all 0.3s ease;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.post-content {
  color: #fff;
}

.post-card h2 {
  font-size: 1.8rem;
  margin-bottom: 1rem;
  background: linear-gradient(45deg, #fff, #88ccff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.post-card p {
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.date {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.9rem;
  display: block;
  margin-top: 1rem;
}

@keyframes glitch {
  0% {
    text-shadow: 0.05em 0 0 rgba(255,0,0,0.75),
                -0.025em -0.05em 0 rgba(0,255,0,0.75),
                0.025em 0.05em 0 rgba(0,0,255,0.75);
  }
  14% {
    text-shadow: 0.05em 0 0 rgba(255,0,0,0.75),
                -0.025em -0.05em 0 rgba(0,255,0,0.75),
                0.025em 0.05em 0 rgba(0,0,255,0.75);
  }
  15% {
    text-shadow: -0.05em -0.025em 0 rgba(255,0,0,0.75),
                0.025em 0.025em 0 rgba(0,255,0,0.75),
                -0.05em -0.05em 0 rgba(0,0,255,0.75);
  }
  49% {
    text-shadow: -0.05em -0.025em 0 rgba(255,0,0,0.75),
                0.025em 0.025em 0 rgba(0,255,0,0.75),
                -0.05em -0.05em 0 rgba(0,0,255,0.75);
  }
  50% {
    text-shadow: 0.025em 0.05em 0 rgba(255,0,0,0.75),
                0.05em 0 0 rgba(0,255,0,0.75),
                0 -0.05em 0 rgba(0,0,255,0.75);
  }
  99% {
    text-shadow: 0.025em 0.05em 0 rgba(255,0,0,0.75),
                0.05em 0 0 rgba(0,255,0,0.75),
                0 -0.05em 0 rgba(0,0,255,0.75);
  }
  100% {
    text-shadow: -0.025em 0 0 rgba(255,0,0,0.75),
                -0.025em -0.025em 0 rgba(0,255,0,0.75),
                -0.025em -0.05em 0 rgba(0,0,255,0.75);
  }
}

@media (max-width: 768px) {
  .hero {
    padding: 4rem 1rem;
  }
  
  .glitch {
    font-size: 2.5rem;
  }
  
  .subtitle {
    font-size: 1.2rem;
  }
}
</style> 